package leetcode.周赛.双周赛.第89场;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2022/10/15 10:29 PM
 * @description：
 */
public class 有效时间的数目 {
    @Test
    public void test() {
        System.out.println(new Solution().countTime("0?:0?"));
    }

    class Solution {
        public int countTime(String time) {
            int ans = 1;
            String[] times = time.split(":");
            String hour = times[0];
            String minute = times[1];
            if (hour.charAt(0) == '?' && hour.charAt(1) == '?') {
                ans *= 24;
            } else {
                if (hour.charAt(0) == '?') {
                    ans *= hour.charAt(1) > '3' ? 2 : 3;
                }
                if (hour.charAt(1) == '?') {
                    ans *= hour.charAt(0) == '2' ? 4 : 10;
                }
            }
            if (minute.charAt(0) == '?' && minute.charAt(1) == '?') {
                ans *= 60;
            } else {
                if (minute.charAt(0) == '?') {
                    ans *= 6;
                }
                if (minute.charAt(1) == '?') {
                    ans *= minute.charAt(0) == '6' ? 1 : 10;
                }
            }
            return ans;
        }
    }
}
